package cn.cloud9.hessianclient.controller;

import cn.cloud9.hessianclient.service.HelloHessian;
import cn.cloud9.hessianclient.util.HessianProxyFactoryUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/hello")
    public String hello() {
        // 服务器暴露出的地址
        String url = "http://localhost:8081/helloHessian.do";
        String msg = null;
        // 客户端接口，需与服务端对象一样
        try {
            HelloHessian helloHessian = HessianProxyFactoryUtil.getHessianClientBean(HelloHessian.class,url);
            msg =  helloHessian.hello("你好");

            System.out.println(msg);

        } catch (Exception e) {
            e.printStackTrace();
        }

        return msg;
    }
}
